// c:\Users\25977\Desktop\新建文件夹 (2)\TayenOrbit\pages\home\home.js
// let common = require("../../common/request")
import http from '../../common/request'
Page({
  data: {
    list: [],
    keyWord: ""
  },
  onLoad(options) {
    this.listApi()
  },
  onConfirm(e) {
    console.log(e, 444)
  },
  onClear() {
    this.setData({
      keyWord: ''
    })
  },
  onInput(e) {
    this.setData({
      keyWord: e.detail.value
    })
  },
  async listApi() {
    await http.request({
      url: '/article/list',
      method: 'GET',
    }).then(({ data }) => {
      console.log(data, 9999)
      this.setData({
        list: data.data
      })
    }).catch((err) => {
      console.log('请求失败', err)
      tt.showLoading({
        title: err.msg
      })
    })
  },
  async onPullDownRefresh() {
    await this.listApi()
    await tt.stopPullDownRefresh();
  },
  toDetail(e) {
    const infoId = e.currentTarget.dataset.itemId
    tt.navigateTo({
      url: `/pages/home/new-detail/new-detail?id=${infoId}`
    });
  },


})